package org.whuims.pois.report.chart2Pic;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

import java.awt.*;
import java.io.File;
import java.io.IOException;

/**
 * Created by john on 2015/5/23.
 */
public class Test {

    public static void main(String[] args) {

        DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
        dataset1.addValue(100, "JAVA","1");
        dataset1.addValue(200, "js", "1");
        dataset1.addValue(200, "C++", "2");
        dataset1.addValue(300, "C", "3");
        dataset1.addValue(400, "HTML", "4");
        dataset1.addValue(400, "CSS", "5");

        StandardChartTheme standardChartTheme=new StandardChartTheme("CN");
        standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
        standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 15));
        standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 15));
        ChartFactory.setChartTheme(standardChartTheme);

        JFreeChart chart = ChartFactory.createBarChart3D("编程语言", "语言",
                "人数", dataset1, PlotOrientation.VERTICAL, true, false,
                false);

        try {
            ChartUtilities.saveChartAsPNG(new File("F:/BarChart3D.png"), chart, 800, 500);
            System.out.println("done");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
